/*
TABLE 1
Association between Firm-Level Exposure to PSL Mandates and Workers' reports of Access to PSL in States and Counties without PSL mandate
*/

cd "$exhibits_path"


use "$data_path/main_analysis_file.dta", clear

	global demog i.gender i.race2_harm c.age_text_clean i.kids i.eslhome i.enrolled i.cohabstatus
	global work i.manager i.longwork_yrs i.union c.hourwage_clean c.usualhours_clean 
	global statechars c.unionmem_pc c.unemp_rate  c.minwage_state  	c.race_black c.race_amind c.race_asian c.race_pacisl c.race_multi c.race_other c.hispan c.age_u5 c.age_5to9 c.age_10to14 c.age_75to84 c.age_85plus c.female_pc c.educ_pc_hsgrad c.educ_pc_somecoll c.educ_pc_assoc c.educ_pc_bach c.educ_pc_grad

	global empchars i.shift_ind c.total_emps c.total_ests

	
*** obtaining estimates ***

* demographic controls only
eststo col1row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog if  psl_law_places_hybd == 0, vce(cluster statelist)
eststo col1row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog if  psl_law_places_hybd == 0, vce(cluster statelist)

* demographic and work controls
eststo col2row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog  $work  if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col2row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog  $work  if  psl_law_places_hybd == 0, vce(cluster statelist) 

* demographic, work, and employer charachteristics
eststo col3row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $empchars if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col3row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $empchars if  psl_law_places_hybd == 0, vce(cluster statelist) 

* demographic, work, employer charachteristics, and state charachteristics
eststo col4row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $empchars $statechars if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col4row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $empchars $statechars if  psl_law_places_hybd == 0, vce(cluster statelist) 


* demographic, work, employer charachteristics, state charachteristics, state fixed effects
eststo col5row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $empchars $statechars i.statelist if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col5row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $empchars $statechars i.statelist if  psl_law_places_hybd == 0, vce(cluster statelist) 

* demographic, work, employer charachteristics, state charachteristics, state fixed effects, year fixed effects
eststo col6row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col6row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_places_hybd == 0, vce(cluster statelist) 



*******************
**** EXPORTING ****
*******************

*variable stack labels
label var pct_emps_psl_state "\hspace{0.5cm} Percent of Workers"
label var pct_ests_psl_state "\hspace{0.5cm} Percent of Establishments"
label var pct_emps_psl_place "\hspace{0.5cm} Percent of Workers"
label var pct_ests_psl_place "\hspace{0.5cm} Percent of Establishments"

*labels for control columns 
estadd local DCchecka "\checkmark": col1row4 col2row4 col3row4 col4row4 col5row4 col6row4 
estadd local WCchecka "\checkmark": col2row4 col3row4 col4row4 col5row4 col6row4 
estadd local STATEchecka "\checkmark": col5row4 col6row4 
estadd local YEARcheckb "\checkmark": col6row4 
estadd local SCchecka  "\checkmark": col4row4 col5row4 col6row4
estadd local INDchecka "\checkmark":  col3row4 col4row4 col5row4 col6row4

*export as .tex table!
esttab col1row3 col2row3 col3row3 col4row3 col5row3 col6row3 using "$exhibits_path\Table 1.tex", ///
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{6}{c}} \hline\hline") ///
	fragment keep(*psl*) ///
	 eqlabels(none) noomitted noconstant nonumbers nonote noobs not nodepvars  label b(%9.3f) ///
	 refcat(pct_emps_psl_place "\vspace{0.1em} \textit{Share in a PSL Covered State or County}", nolabel) ///
	 star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	 	 mgroups("\shortstack{ Workers in non-PSL States or Counties}", pattern(1 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) mtitles("M1" "M2" "M3" "M4" "M5" "M6") ///
	replace 
		
esttab col1row4 col2row4 col3row4 col4row4 col5row4 col6row4 using "$exhibits_path\Table 1.tex", ///
	fragment keep(*psl*) ///
	postfoot("\hline\hline \multicolumn{7}{l}{\footnotesize \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\ \end{tabular} } ") ///
	nomtitles eqlabels(none) noomitted noconstant not nonote noobs  nodepvars nonumbers nolines label b(%9.3f) /// 
	scalars("DCchecka Demographic Controls" "WCchecka Work Controls" "INDchecka Firm Controls" "SCchecka State Controls" "STATEchecka State FE" "YEARcheckb Year, Month, Year $\times$ Month FE"   "line \hline \vspace{-.4em}" "N N") ///
	sfmt(%9.0f) ///
	prefoot("\vspace{0.3cm} \\") ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	append
	

